-
Notifications
You must be signed in to change notification settings - Fork 7
Fix existing E2E test failures and Improve resource cleanup #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
Signed-off-by: hlts2 <[email protected]>
This reverts commit a69ce30.
Signed-off-by: hlts2 <[email protected]>
@@ -3,7 +3,7 @@ module github.com/civo/civo-cloud-controller-manager | |||
go 1.24.1 | |||
|
|||
require ( | |||
github.com/civo/civogo v0.3.61 | |||
github.com/civo/civogo v0.3.96 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Since civo-cloud-controller-manager will not be released immediately, there should be no impact on the existing environment. However, if the version update is unnecessary, I will revert this changes. 🙏
@@ -5,7 +5,7 @@ e2e tests for the Civo Cloud Controller Manager. | |||
These tests can be run: | |||
|
|||
```bash | |||
CIVO_API_KEY=.... go test --timeout 30 -v ./e2e/... | |||
CIVO_API_KEY=.... go test -timeout 20m -v ./... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
The command was incorrect, so I have fixed it. Additionally, since it didn't finish within 30 seconds, I have changed the timeout to 20 minutes.
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
) | ||
|
||
func TestLoadbalancerBasic(t *testing.T) { | ||
|
||
ctx := t.Context() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Since t.Context was introduced in Go 1.24, I used it. This will allow for proper cancellation handling.
g.Expect(err).ShouldNot(HaveOccurred()) | ||
defer e2eTest.tenantClient.Delete(context.TODO(), mirrorDeploy) | ||
t.Cleanup(func() { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
It is recommended to use t.Cleanup in tests, so I used it. Additionally, since t.Context cannot be used internally, I am using a context with a timeout.
}, | ||
}, | ||
FirewallRule: "443;80", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
I have set the firewall_rule based on the following error that occurred during cluster creation.
Unable to provision new cluster: Error: Unknown error response - status: 400 Bad Request, code: 400, reason: {"code":"firewall_missing","reason":"Please provide either instance_firewall or firewall_rule"}
Unable to provision new cluster: Error: Unknown error response - status: 400 Bad Request, code: 400, reason: {"code":"firewall_missing","reason":"Please provide either instance_firewall or firewall_rule"}
|
||
lbls := map[string]string{"app": "mirror-pod"} | ||
// Create a service of type: LoadBalancer | ||
svc := &corev1.Service{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "echo-pods", | ||
Namespace: "default", | ||
Annotations: map[string]string{ | ||
"kubernetes.civo.com/firewall-id": e2eTest.cluster.FirewallID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
After correcting the previous comment, the following error occurred during service creation, so I made adjustments based on the details of that error.
"Event occurred" object="default/echo-pods" fieldPath="" kind="Service" apiVersion="v1" type="Warning" reason="SyncLoadBalancerFailed" message=<
Error syncing load balancer: failed to ensure load balancer: Error: Unknown error response - status: 400 Bad Request, code: 400, reason: {"code":"firewall_missing","reason":"Please provide either instance_firewall or firewall_rule"}
@@ -79,6 +91,7 @@ func TestLoadbalancerProxy(t *testing.T) { | |||
Namespace: "default", | |||
Annotations: map[string]string{ | |||
"kubernetes.civo.com/loadbalancer-enable-proxy-protocol": "send-proxy", | |||
"kubernetes.civo.com/firewall-id": e2eTest.cluster.FirewallID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Same as the below comment.
https://github.com/civo/civo-cloud-controller-manager/pull/37/files#r2031178002
Name: "echo-pods", | ||
Namespace: "default", | ||
Annotations: map[string]string{ | ||
"kubernetes.civo.com/firewall-id": e2eTest.cluster.FirewallID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Same as the below comment.
https://github.com/civo/civo-cloud-controller-manager/pull/37/files#r2031178002
@@ -142,7 +142,7 @@ func (e *E2ETest) provisionCluster() { | |||
CivoRegion = "LON1" | |||
} | |||
|
|||
CivoURL := os.Getenv("CIVO_URL") | |||
CivoURL := os.Getenv("CIVO_API_URL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
I changed it because the name was different from the expected one.
@@ -178,9 +178,10 @@ func (e *E2ETest) provisionCluster() { | |||
Pools: []civogo.KubernetesClusterPoolConfig{ | |||
{ | |||
Count: 2, | |||
Size: "g4s.kube.xsmall", | |||
Size: "g4s.kube.small", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
Just to be safe, I changed it to "small" in case it doesn't start.
}, "2m", "5s").ShouldNot(BeNil()) | ||
} | ||
|
||
func TestLoadbalancerHTTPForwardFor(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note
The following test was added three years ago, but after catching up on an internal Slack message(Apr 5th, 2024) about not returning x-forwarded-for, I decided to remove it this time.
#8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DMajrekar
Is this understanding correct? 🤔 If so, I will make the necessary changes to the README in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed that the current test is out of date and can be removed
We now support this via a proxy_protocol flag
https://www.civo.com/docs/kubernetes/load-balancers#proxy-protocol
we should either add a test here, or add and link an issue for a future addition of a test for this functionally. Your choice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
opened #38 it in case it doesn't make it in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment 🙏
I'll go ahead and add a test for this functionality in the next PR to ensure it's covered.
issue: #38
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johndietz Thank you for creating issue! 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr, description, and comments are all great @hlts2 thank you so much
@DMajrekar @johndietz |
WHAT
This PR includes the following changes:
WHY
There are plans to expand E2E testing in the future. By ensuring that the existing tests are in a working state beforehand, other members will be able to add tests more easily. If the existing tests are failing, it would delay the process, as work would need to start with fixing the existing issues. Therefore, the goal of this PR is to make sure that the existing tests are functional and ready to be expanded at any time.
I encountered the following errors when running the tests, so I've addressed them in this PR:
Additionally, resources were not being released correctly, preventing tests from running consecutively. This PR includes fixes related to proper resource cleanup, particularly using Context and handling cleanup processes.
Test
go test -count=1 -timeout 20m -v ./e2e/...
Test Result
FYI